<?php
/**
 * Created by viva.
 * User: xj
 * Tel:  13675170078
 * Date: 2015/6/10
 * Time: 15:05
 */
namespace Admin\Model;

use Think\Model;

class UserModel extends Model
{
    public function checkLogin($user_name,$password)
    {
        if( $user_name && password ) {
            $where['user_name'] = $user_name;
            $result=$this->where($where)->find();
            if($result)
            {
                if($result['password']==md5($password)) {
                    session('user_data', $result);
                    return 1;//登录成功
                }
                else
                    return 0;//密码错误
            }
            else
                return -1;//账号不存在

        }

    }

}